<%@page import="business.BusinessSeries"%>
<%@page import="domain.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" import="domain.User,java.util.*" %> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>PelSer | Resultado</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
	<!-- Stylesheets -->
	<link rel="stylesheet" href="css/reset.css" />
	<link rel="stylesheet" href="css/styles.css" />
	<link rel="stylesheet" href="css/input.css" />
	
	<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/input.js"></script>
	
	<!-- Scripts -->
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
	<script type="text/javascript"  src="js/contact.js"></script>
</head>
<body>
<div id="wrapper" class="container_12 clearfix">

		<!-- Text Logo -->
		<h1 id="logo" class="grid_4"><a href="index.jsp">PelSer</a></h1>
		<div>
		<!-- Navigation Menu -->
        <ul id="navigation" class="grid_8">
            <li><a href="films.jsp"><span class="meta">Tus Peliculas</span><br />Top</a></li>
            <li><a href="messages.html"><span class="meta">Tus mensajes</span><br />Mensajes</a></li>
            <li><a href="friends.jsp"><span class="meta">Tus Amigos</span><br />Amigos</a></li>
            <li><a href="profile.jsp"><span class="meta">Tu perfil</span><br />Perfil</a></li>
            <li><a href="wall.jsp"><span class="meta">Novedades</span><br />Muro</a></li>
        </ul></div><div>
        	<table width="100%">
        	<tr>
        		<td>
        		<form action="FrontControllerSearch" method="post">
        		<label class="input">
    			<span>Buscar...</span>
    			<input type="text"  name="busquedaSimple"/>
				</label>
        		<input type="hidden" name="rdtema" value="buscarSimple"/>
				<a href="search.jsp">Busqueda Avanzada</a>
				</form>
				</td>
        	 	
        	 	<% if(session.getAttribute("session.user")!=null){
        	 		User usuario= (User)(session.getAttribute("session.user"));
        	 		
        	 	%>
        	 	
        	 	<td align="right">
        	 	<form action="FrontControllerLogin?accion=logout" method="post">
        	 	<input type="image" title="Salir" src="images/logout.gif" ondblclick="this.form.submit()"></input>
        	 	</form>
        	 	 
        	 	<% 
        	 	out.print("<i>Bienvenid@: <b>"+usuario.getName()+" "+usuario.getSurname()+"</b></i>");
        	 	
        	 	} %>
        	 	
        	 	</td>
        	</tr>
        	</table>
        </div>
			
		<div class="hr grid_12 clearfix">&nbsp;</div>
			
		<!-- Caption Line -->
		<h2 class="grid_12 caption clearfix"> <span>Resultado Busqueda Avanzada</span>!</h2>
			<div class="grid_9">
			<% 
				Integer pagina=0;
				if(request.getParameter("pagina")!=null){
					pagina = new Integer(request.getParameter("pagina"));
				}
				
				List<?> resultado = new LinkedList<Video>();
				String tipo = (String)request.getAttribute("tipo");
				if(request.getAttribute("resultado") instanceof List<?>)
				{
					if(tipo.equals("peliculas")){
						resultado=(List<Movie>)request.getAttribute("resultado");
					}else if(tipo.equals("series")){
						resultado=(List<Series>)request.getAttribute("resultado");
					}else{
						resultado=(List<Video>)request.getAttribute("resultado");
					}
				}
				int prim_libro=pagina * 10; 
				for (int i = prim_libro; i < resultado.size() && i < prim_libro + 10; i++) {
					Video video=(Video)resultado.get(i);
					String ref="movie.jsp?idVideo="+video.getIdVideo();
					if(BusinessSeries.getSeriesByTitle(video.getTitle())!=null){
						ref="serie.jsp?idVideo="+video.getIdVideo();
					}
					%>
					<a name="video"  class="portfolio_item float alpha" href=<%out.print(ref); %>>
						<span><%out.print(video.getTitle()); %></span>
						<img class="" src=images/<%if(video.getCover()!=null){out.print(video.getCover());}else{out.print("noimage.jpg");} %>  alt=""/>
					</a>
					<% 
				} 
			%> 
			</div>
			
		
		<div class="hr grid_12 clearfix">&nbsp;</div>

		<!-- Column 1 / Content -->
		<div class="grid_8">
			<a href="films.jsp?pagina=<%=pagina - 1%>">Anterior</a> 
			<a href="films.jsp?pagina=<%=pagina + 1%>">Siguiente</a> 
		</div>
		
		<!-- Column 2 / Sidebar -->
		<div class="grid_4 contact">
		
			
		</div>
		
		<div class="hr grid_12 clearfix">&nbsp;</div>
		
		<!-- Footer -->
		<p class="grid_12 footer clearfix">
			<span class="float"><b>&copy; Copyright</b> <a href="">Grupo 12</a></span>
			<a class="float right" href="#">Subir</a>
		</p>
		
	</div><!--end wrapper-->
</body>
</html>